package onjava.arrays;

// arrays/ParallelSetAll.java
// (c)2021 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
import java.util.*;
import onjava.*;
import onjava.Timer;

/**
 * 
 * 性能比较
 *
 * @see ParallelSetAll
 * @author Lucky Yang
 */
public class ParallelSetAll1 {
  static final int SIZE = 10_000_000;

  static void setAll() {
    int[] ia = new int[SIZE];
    Arrays.setAll(ia, new Rand.Pint()::get);
  }

  static void parallelSetAll() {
    int[] ia = new int[SIZE];
    Arrays.parallelSetAll(ia, new Rand.Pint()::get);
  }

  public static void main(String[] args) {
    System.out.println("setAll: " + Timer.duration(ParallelSetAll1::setAll));
    System.out.println("parallelSetAll: " + Timer.duration(ParallelSetAll1::parallelSetAll));
  }
}
